import matplotlib.pyplot as plt
import numpy as np
from sklearn import linear_model

x = np.linspace(3, 8, 20)

y = 2 * x + 1

x = x + np.random.rand(20)

x = [[i] for i in x]
y = [[i] for i in y]

model = linear_model.LinearRegression()
model.fit(x, y)

x_ = [[4], [5], [6]]
y_ = model.predict(x_)

print(y_)

plt.scatter(x, y)

plt.plot(x_, y_, color="red", linewidth=3.0, linestyle="-")

plt.legend(["func", "Data"], loc=0)

plt.show()
